package com.wander.concurrent;

import java.util.concurrent.atomic.AtomicInteger;

public class AtomicIntegerExample {
    private static final int threadNum = 10000;
    private static Integer count = 0;
    private static AtomicInteger atomicInteger = new AtomicInteger(0);
    public static void main(String[] args) {

        for (int i = 0; i < threadNum; i++) {
            new Thread(()->{
                try {
                    for (int j = 0; j < Integer.MAX_VALUE; j++) {
                        
                    }
                    count = atomicInteger.incrementAndGet();
                    System.out.println(count);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }).start();
        }
    }
}
